From 2c8961d7af3d246bbc4a379d447c400def01e0da Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Wed, 11 Jul 2018 23:35:59 +0200 Subject: [PATCH] babl: add babl_model_is, utility function for checking model equivalence This creates an on the fly model with the same space as the one compared with and does pointer equivalence. Using it makes for less verbose code. --- babl/babl.c | 8 ++++++++ babl/babl.h | 3 +++ export-symbols | 1 + 3 files changed, 12 insertions(+) diff --git a/babl/babl.c b/babl/babl.c index c734fb3..3d7573e 100644 --- a/babl/babl.c +++ b/babl/babl.c @@ -180,3 +180,11 @@ babl_exit (void) #endif } } + +#undef babl_model_is + +int babl_model_is (const Babl *babl, const char *model) +{ + return ((babl)==babl_model_with_space(model, babl)); +} + diff --git a/babl/babl.h b/babl/babl.h index 660138f..f0dc852 100644 --- a/babl/babl.h +++ b/babl/babl.h @@ -501,6 +501,9 @@ const Babl * babl_trc (const char *name); * query thechromaticities of white point and primaries as well as trcs * used for r g a nd b, all arguments mights be NULL. */ +int babl_model_is (const Babl *babl, const char *model); + +#define babl_model_is(babl,model) ((babl)==babl_model_with_space(model,babl)) void babl_space_get (const Babl *space, double *xw, double *yw, diff --git a/export-symbols b/export-symbols index f9d0a1c..130f616 100644 --- a/export-symbols +++ b/export-symbols @@ -31,6 +31,7 @@ babl_init babl_introspect babl_malloc babl_model +babl_model_is babl_model_with_space babl_model_new babl_new_palette -- 2.30.2